function data = ReadOneRun(Format,FileName,RunID,RecordNumPerSet)
% data = ReadOneRun(Format,FileName,RunID) returns the #RUNID run
% data = ReadOneRun

% Format = 'mpc' ------------------------------------------
% Column            Variable
% 1                 Run#   
% 2                 t(s)
% 3-7               W[1]~w[5]
% 8                 cost
% 9                 ht
% 10                r2
% 11                g_dens
% 12-31             alpha[0]~[19]
% 32-51             beta[0]~[19]
% 52-56             uplim[0]~[4]
% 57-61             lolim[0]~[4]
%
% Format = 'kmc' ------------------------------------------
% Column            Variable
% 1                 Run#
% 2                 t(s)
% 3                 T(K)
% 4                 W (Layer/s)
% 5                 rho_s
% 6                 rho_g
% 7                 h
% 8                 r2
% 9-28              alphas[0]-[19]
% 29-48             betas[0]-[19]
%
% Format = 'gas phase'
% Column            Variable


if(strcmp(Format,'mpc'))
    HeaderLineNum = 14;
    ColumnNum  = 61;
elseif(strcmp(Format,'kmc'))
    HeaderLineNum = 13;
    ColumnNum = 48;
elseif(strcmp(Format,'gasphase'))
    t = [];
    Var = [];
    return;
end

fid = fopen(FileName);
FormatString_Column1= '%d %f';
for j = 3:61
    FormatString_Column1 = strcat(FormatString_Column1,' %*f');
end
data0 = textscan(fid,FormatString_Column1,'HeaderLines',14);

IDs = data0{1};
TotalRecordNum = length(IDs);
RecordSetsNum = max(IDs);
RecordNumPerSet = TotalRecordNum/RecordSetsNum;

FormatString= '%d';
for j = 2:61
    FormatString = strcat(FormatString,' %f');
end
frewind(fid);
data = textscan(fid,FormatString,RecordNumPerSet,'HeaderLines',14*(RunID-1)*RecordNumPerSet);

assert(all(data{1}==RunID));